package com.xinchuang.controller.targetSystem.systems;

import com.xinchuang.common.Result;
import com.xinchuang.entity.targetSystem.object.SystemsIndexAdd;
import com.xinchuang.fiter.NoToken;
import com.xinchuang.service.targetSystem.ArchitectureService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @ClassName ArchitectureController
 * @Description: TODO(体系结构新增需求controller)
 * @Author zhangxuan
 * @Date 2021-05-13 10:30
 * @Verion V1.0
 */
@Api(tags = "体系结构新增需求controller")
@RestController
@RequestMapping(value = "/architecture")
public class ArchitectureController {

    @Resource
    private ArchitectureService architectureService;

    /**
     * 指标下拉列表
     */
    private static final String SELECT_INDEX_PULL = "/indexPull";
    /**
     * 查询系统待选信息列表
     */
    private static final String SELECT_WAIT_DATA_LIST = "/queryWaitList";
    /**
     * 添加待选目标到系统
     */
    private static final String INSERT_INDEX_TARGET_LIST = "/addTargetList";
    /**
     * 查询指数列表
     */
    private static final String SELECT_INDEX_DATA = "/indexData";
    /**
     * 查询系统已选信息列表
     */
    private static final String SELECT_CONFIRM_DATA_LIST = "/queryConfirmList";

    @ApiOperation(value = "查询单个系统指标列表")
    @GetMapping(SELECT_INDEX_PULL)
    public Result getSystemIndexList(
            @RequestParam(value = "sysId")String sysId
    ) {
        return architectureService.selectIndexPull(sysId);
    }

    @ApiOperation(value = "查询系统待选信息列表")
    @GetMapping(SELECT_WAIT_DATA_LIST)
    public Result getSystemWaitDataList(
            @RequestParam(value = "pageNum",defaultValue = "1")Integer pageNum,
            @RequestParam(value = "pageSize", defaultValue = "10")Integer pageSize,
            @RequestParam(value = "sysId")String sysId,
            @RequestParam(value = "index",required = false)String index
    ) {
        return architectureService.selectSystemWaitList(pageNum, pageSize, sysId, index);
    }

    @ApiOperation(value = "添加待选目标到系统")
    @PostMapping(INSERT_INDEX_TARGET_LIST)
    public Result addWaitDataToConfirmData(
            @Validated @RequestBody SystemsIndexAdd systemsIndexAdd
    ) {
        return architectureService.insertConfirmIndex(systemsIndexAdd.getRelationList(), systemsIndexAdd.getSysId(), systemsIndexAdd.getStatus());
    }

    @ApiOperation(value = "查询指数列表")
    @GetMapping(SELECT_INDEX_DATA)
    public Result selectIndexData(
            @RequestParam(value = "sysId")String sysId
    ) {
        return architectureService.selectSystemIndexList(sysId);
    }

    @ApiOperation(value = "查询系统已选信息列表")
    @GetMapping(SELECT_CONFIRM_DATA_LIST)
    public Result getSystemConfirmDataList(
            @RequestParam(value = "pageNum",defaultValue = "1")Integer pageNum,
            @RequestParam(value = "pageSize", defaultValue = "10")Integer pageSize,
            @RequestParam(value = "sysId")String sysId,
            @RequestParam(value = "index",required = false)String index,
            @RequestParam(value = "taskId",required = false)Integer taskId
    ) {
        return architectureService.selectSystemConfirmList(pageNum, pageSize, sysId, index, taskId);
    }

}